<extend name="Public/base"/>
<block name="style">	
	<link rel="stylesheet" href="__JS__/colorbox/colorbox.min.css">
</block>
<block name="content">
<h3>歌曲管理</h3>
<div class="panel panel-default">
	<div class="panel-heading"><{:isset($data['id'])?'编辑':'新增'}>歌曲</div>
 	<div class="panel-body">
        <form class="form-horizontal" enctype="multipart/form-data" action="<{:U()}>" name="songs"  method="post">	
       		<div class="form-group">	
				<label class=" col-sm-2 control-label">歌曲名称</label>
				<div class="col-sm-3">
					<input  type="text"  name="name" value="<{$data.name|default=''}>" class="form-control">					
				</div>
				<span class="help-block">此项不能为空</span>
			</div>	

			<div class="form-group">	
				<label class="col-sm-2 control-label">所属曲风</label>
				<div class="col-sm-3">
					<select name="genre_id" class="form-control">
	        		<volist name=":get_genre_tree()" id="genre">	        			
	            		<option <if condition="$data['genre_id'] eq $genre['id'] ">selected='selected'</if> value="<{$genre.id}>"><{$genre.title_show}></option>
	        		</volist>
					</select>
				</div>	
			</div>	

    		<div class="form-group">	
    			<label class="col-sm-2 control-label">所属艺术家</label>
    			<div class="col-sm-3">
    				<div class="input-group">
    					<input type="text" class="hide" id="artist-id" name="artist_id" value="<{$data.artist_id|default='0'}>">	
    					<input type="text" class="form-control" id="artist-name" name="artist_name"  value="<{$data.artist_name|default='佚名'}>">	
						<a href="#" class="input-group-addon" id="f-s-btn" rel="artist">
                         	<span class="fa-search fa"></span>
                    	</a>
                    </div>
    			</div>	
    			
    			<label class="col-sm-1 control-label">所属用户</label>
    			<div class="col-sm-1">
    				<div class="input-group">	
    					<input type="text" class="form-control"  name="up_uid"  value="<{$data.up_uid|default='0'}>">	
                    </div>                   
    			</div>	
    			<p class="help-block col-sm-2">填写会员ID</p>						
    		
    		</div>
    		
    
    		<div class="form-group">	
    			<label class="col-sm-2 control-label">所属专辑</label>
    			<div class="col-sm-3">
   					<div class="input-group">
    					<input type="text"  class="hide" name="album_id" id="album-id" value="<{$data.album_id|default='0'}>">
    					<input type="text" class="form-control"  name="album_name" id="album-name" value="<{$data.album_name|default='单曲'}>">
						<a href="#" class="input-group-addon" id="f-a-btn" rel="album">
                         	<span class="fa-search fa"></span>
                    	</a>
                    </div>
    			</div>	
    		</div>
    		
    		<div class="form-group">	
				<label class="col-sm-2 control-label">所属服务器</label>
				<div class="col-sm-2">
					<select name="server_id" class="form-control">
						<option>无服务器</option>
	        			<volist name=":get_server()" id="server">	        			        			
	            		<option <if condition="C('Dt_SERVER_ID') eq $server['id'] ">selected='selected'</if> value="<{$server.id}>" data-down="<{$server.downPath}>"  data-listen="<{$server.listenPath}>" ><{$server.name}></option>
	        			</volist>
					</select>
				</div>
				<span class="help-block"></span>
			</div>	
    		    			   
    		<div class="form-group">	
    			<label class="col-sm-2 control-label">歌曲地址</label>
    			<div class="col-sm-5">
    				<div class="input-group">
    					<input type="text" class="form-control" name="music_url"  id="songs_url"  value="<{$data.music_url|default=$Server['listenPath']}>">
    					<a href="#" class="input-group-addon up-s-btn" fileType="*.mp3; *.mp4; *.wma; *.ogg;"  rel="#songs_url">
                        	<span class="fa fa-cloud-upload"></span>
                    	</a>
                    </div>    				
    			</div>
    			<span class="help-block">本地上传自动获取URL</span>
    		</div>		
    	
    		<div class="form-group">	
    			<label class="col-sm-2 control-label">下载地址</label>
    			<div class="col-sm-5">
    				<div class="input-group">
    					<input type="text"  class="form-control" name="music_down" id="music-down" value="<{$data.music_down|default=$Server['downPath']}>">
    					<a href="#" class="input-group-addon up-s-btn" fileType="*.mp3; *.mp4; *.wma; *.ogg;"  rel="#music-down">
                        	<span class="fa fa-cloud-upload"></span>
                    	</a>
    					<a href="#" class="input-group-addon" id="set-down-url" rel="#songs_url">同上</a>
    				</div> 
    			</div>	
    		</div>      		   	
    		 		
    		<div class="form-group">
				<label class="col-sm-2 control-label">歌曲封面</label>
				<div class="col-sm-3">
					<input type="file" id="upload_picture">
					<input type="hidden" id="cover_id" name="cover_id" value="<{$data.cover_id}>"/>
					<div class="upload-img-box">
					<notempty name="data['cover_id']">
						<div class="upload-pre-item"><img src="<{$data.cover_id|getcover}>"/></div>
					</notempty>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">封面外链</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="cover" value="<{$data.cover}>"/>
					<div class="upload-img-box">
					<notempty name="data['cover']">
						<div class="upload-pre-item"><img src="<{$data.cover}>"/></div>
					</notempty>
					</div>
				</div>
				<p class="help-block">封面图片外链地址/优先级低于站内上传</p>
			</div>	
    		<!--div class="form-group">	
    			<label class="col-sm-2 control-label">生成波纹图片</label>
    			<div class="col-sm-2 controls">
					<input class="hide" name="create_bowen" value="<{$data.create_bowen |default='0'}>">
					<if condition="$data.create_bowen == 1">
					<div class="switch-wrapper">
						<span class="switch-enable selected">是</span>
						<span class="switch-disable">否</span>
					</div>
					<else/>
					<div  class="switch-wrapper">
						<span class="switch-enable">是</span>
						<span class="switch-disable selected">否</span>	
					</div>
					</if>
                </div>
                <span class="help-block">串烧歌曲不建议生成！</span>				
    		</div-->	
			<div class="form-group">						
    			<label class="col-sm-2 control-label ">试听次数</label>
    			<div class="col-sm-1 controls">
    				<input type="text" class="form-control"  value="<{$data.listens|default=''}>" name="listens">
    			</div>	
		
    			<label class="col-sm-1 control-label ">评分</label>
    			<div class="col-sm-1">
    				<input type="text" class="form-control input-mini"  value="<{$data.rater|default='0'}>" name="rater">    				
    			</div>
    			<span class="help-block col-sm-1">最高10分</span>
				
				<label class="col-sm-1 control-label ">下载积分</label>
    			<div class="col-sm-1">
    				<input type="text" class="form-control input-mini"  value="<{$data.gold|default='0'}>" name="gold">    				
    			</div>
    			
    			<label class="col-sm-1 control-label ">下载音质</label>
    			<div class="col-sm-1">
    				<input type="text" class="form-control input-mini"  value="<{$data.tone|default='320k'}>" name="down_bit">    				
    			</div>
    			    			    							
    		</div>
    		
    		<div class="form-group">		
				<label class="col-sm-2 control-label">推荐</label>
    			<div class="col-sm-3 controls">
					<input class="hide" name="recommend" value="<{$data.recommend}>">
					<if condition="$data.recommend == 1">
					<div class="switch-wrapper">
						<span class="switch-enable selected">是</span>
						<span class="switch-disable">否</span>
					</div>
					<else/>
					<div  class="switch-wrapper">
						<span class="switch-enable">是</span>
						<span class="switch-disable selected">否</span>	
					</div>
					</if>
                </div>	
    	    </div>	
    		
    		<!--div class="form-group">
				<label class="col-sm-2 control-label">推荐位</label>
		        <div class="col-sm-3">
			    	<label class="checkbox">
		             	<input type="checkbox" name="position[]" value="1">列表推荐	
		            </label>
		            <label class="checkbox">
		            	<input type="checkbox" name="position[]" value="2">置顶推荐	
		             </label>  	            		            	
	            </div>				                   		            	
	            <span class="check-tips">默认不推荐</span>
			</div>
    		<div class="form-group">		
    			<label class="col-sm-2 control-label ">bmp</label>
    			<div class="col-sm-1">
    				<input type="text" class="form-control input-mini"  value="<{$data.bpm|default=''}>" name="bpm">    				
    			</div>
    	    </div-->
    	    
    	    <div class="form-group">	
				<label class=" col-sm-2 control-label">标题</label>
				<div class="col-sm-3">
					<input  type="text"  name="title" value="<{$data.title|default=''}>" class="form-control">					
				</div>
				<span class="help-block">SEO标题</span>
			</div>	
			
			<div class="form-group">	
				<label class=" col-sm-2 control-label">关键字</label>
				<div class="col-sm-3">
					<input  type="text"  name="kerwords" value="<{$data.kerwords|default=''}>" class="form-control">					
				</div>
				<span class="help-block">SEO关键字</span>
			</div>	
			
			<div class="form-group">	
				<label class=" col-sm-2 control-label">描述</label>
				<div class="col-sm-4">
					<input  type="text"  name="description" value="<{$data.description|default=''}>" class="form-control">					
				</div>
				<span class="help-block">SEO描述</span>
			</div>	
    	    
    		<div class="form-group">
    			<input type="hidden" name="status" value="<{$data.status|default=''}>">       		
    			<input type="hidden" name="id" value="<{$data.id|default=''}>">
            	<div class="col-sm-4 col-sm-offset-2">
                	<button class="btn btn-default" type="button" onclick="javascript:history.back(-1);return false;">取消</button>
                	<button class="btn btn-primary ajax-post" target-form="form-horizontal" type="submit">保存</button>
            	</div>
        	</div>
        </form>
	</div>
</div>

</block>
<block name="script">
<script type="text/javascript" src="__JS__/colorbox/jquery.colorbox.min.js"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript"  src="__JS__/other.js"></script>
<script type="text/javascript">			
highlight_subnav("<{:U('Songs/index')}>");		
var findUrl="<{:U('Ajax/findData')}>",upUrl= "<{:U('File/uploadMusic',array('session_id'=>session_id()))}>",swfPath="__STATIC__/uploadify/uploadify.swf",root="__ROOT__";
(function(){
  	//上传图片
    /* 初始化上传插件 */
	$("#upload_picture").uploadify({
        "height"          : 30,
        "swf"             : "__STATIC__/uploadify/uploadify.swf",
        "fileObjName"     : "download",
        "buttonText"      : "上传图片",
        "uploader"        : "<{:U('File/uploadPicture',array('session_id'=>session_id()))}>",
        "width"           : 120,
        'removeTimeout'	  : 1,
        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
        "onUploadSuccess" : uploadPicture
    });
	function uploadPicture(file, data){
    	var data = $.parseJSON(data);
    	//alert(data.path);
        if(data.status){
        	$("#cover_id").val(data.id);
        	$("#cover_id").parent().find('.upload-img-box').html(
        		'<div class="upload-pre-item"><img src=".' + data.path + '"/></div>'
        	);
        } else {
        	topAlert(data.info);
        }
    }
})();

$(function () {
	$("select[name='server_id']").change( function() {
		var option = $(this).find("option:selected");
		$('#songs_url').val(option.attr('data-listen'));
		$('#music-down').val( option.attr('data-down'));
	});
})

</script>

</block>	


